<template>
  <div class="bodyBox">
    <FrameStyle>
      <!-- 面包屑 -->
      <Breadcrumb :breadName="`收藏管理`" slot="breadcrumb" />
      <!-- 搜索框 -->
      <el-input slot="search">
        <el-button class="el-icon-search" slot="append"></el-button>
      </el-input>
      <!-- 添加按钮 -->
      <el-button type="primary" slot="addBtn">添加收藏项</el-button>
      <!-- 表格列表 -->
      <el-table :data="tableData" stripe slot="tableList" height="370px">
        <el-table-column
          label="创建时间"
          prop="createTime"
          width="110px"
        ></el-table-column>
        <el-table-column prop="refId" label="收藏id"></el-table-column>
        <el-table-column prop="userId" label="用户id"></el-table-column>
        <el-table-column
          prop="name"
          label="姓名"
        ></el-table-column>
        <el-table-column label="表名" prop="tableName" width="auto">
        </el-table-column>
        <el-table-column prop="picture" label="封面" width="auto">
          <template slot-scope="scope">
            <img :src="scope.row.picture" height="50px" />
          </template>
        </el-table-column>
        <el-table-column prop="type" label="类型" width="auto">
        </el-table-column>
        <el-table-column label="推荐类型" prop="recommendType" >
        </el-table-column>
        <el-table-column label="操作" width="150px">
          <template>
            <el-button size="mini">修改</el-button>
            <el-button type="danger" size="mini">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页器 -->
      <Pagination
        slot="pageSlot"
        :pageNo="pageNum"
        :pageSize="pageSize"
        :totalRows="totalRows"
        @pageChange="pageChange"
      />
    </FrameStyle>
  </div>
</template>

<script>
import { reqShoucangList } from "../../../api";

export default {
  data() {
    return {
      tableData: [],
      pageNum: 1,
      pageSize:10,
      totalRows: 10,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    //获取收藏表数据
    async getData() {
      let { pageNum, pageSize } = this;
      let result = await reqShoucangList({ pageNum, pageSize });
      if (result.code != 200) return false;
      result.data.list.forEach((item) => {
        item.createTime = this.$format(item.createTime);
      });
      this.tableData = result.data.list;
      this.totalRows = result.data.total;
    },
    //分页
    pageChange(page) {
      this.pageNum = page;
      this.getData()
    },
  },
};
</script>

<style lang="less" scoped>
  .el-table{
    height: 100%;
  }
</style>